package com.gushenge.core.listeners


class SimpleResultListener : ResultListener {

    private var _Success: (() -> Unit)? = null
    fun success(listener: () -> Unit) {
        _Success = listener
    }

    override fun success() {
        _Success?.invoke()
    }


    private var _Error: (() -> Unit)? = null
    fun error(listener: () -> Unit) {
        _Error = listener
    }

    private var _Success1: ((bean: Any) -> Unit)? = null
    fun success(listener: (bean: Any) -> Unit) {
        _Success1 = listener
    }

    private var _Error1: ((error: String) -> Unit)? = null
    fun error(listener: (error: String) -> Unit) {
        _Error1 = listener
    }

    private var _Success2: ((bean: Any, message: String) -> Unit)? = null
    fun success(listener: (bean: Any, message: String) -> Unit) {
        _Success2 = listener
    }

    private var _Success3: ((bean: Any, p: Int, max: Int) -> Unit)? = null
    fun success(listener: (bean: Any, p: Int, max: Int) -> Unit) {
        _Success3 = listener
    }

    private var _Success4: ((bean: Any, p: Int, max: Int, message: String) -> Unit)? = null
    fun success(listener: (bean: Any, p: Int, max: Int, message: String) -> Unit) {
        _Success4 = listener
    }

    override fun success(beans: Any, p: Int, max: Int) {
        _Success3?.invoke(beans, p, max)
    }

    override fun success(beans: Any, p: Int, max: Int, message: String) {
        _Success4?.invoke(beans, p, max, message)
    }

    override fun success(bean: Any, message: String) {
        _Success2?.invoke(bean, message)
    }

    override fun success(bean: Any) {
        _Success1?.invoke(bean)
    }

    override fun error(error: String) {
        _Error1?.invoke(error)
    }
    override fun error() {
        _Error?.invoke()
    }
}